﻿using System;
using Firefly.Framework.Input;
using Firefly.Framework.Windows;
using Firefly.Framework.Windows.Forms;
using Microsoft.Xna.Framework;

namespace WindowsExample.Windows
{
    public class LoginDialog
    {
        private Game _game;
        private Form _form;
        private Textbox _userName;
        private Textbox _password;
        private Button _login;
        private Button _cancel;

        public LoginDialog(Game game)
        {
            _game = game;
            _form = (Form)WindowsService.Instance.FindComponent("_loginDialog");
            _userName = (Textbox)_form.FindComponent("_userName");
            _password = (Textbox)_form.FindComponent("_password");
            _login = (Button)_form.FindComponent("_login");
            _login.Clicked += new EventHandler<MouseButtonMapEventArgs>(OnLogin);
            _cancel = (Button)_form.FindComponent("_cancel");
            _cancel.Clicked += new EventHandler<MouseButtonMapEventArgs>(OnCancel);
        }

        public void Focus()
        {
            _form.Focus();
        }

        private void OnLogin(object sender, MouseButtonMapEventArgs e)
        {
            MessageBox.Show("Woot", "You clicked a button");
        }

        private void OnCancel(object sender, MouseButtonMapEventArgs e)
        {
            _game.Exit();
        }
    }
}
